package com.lgh.demo.util;

import android.content.Context;
import android.databinding.BindingAdapter;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.lgh.demo.GlideApp;
import com.lgh.demo.R;

/**
 * Created by oo on 2017/9/20.
 */

public class ImageToos {

    @BindingAdapter({"imgUrl"})
    public static void loadImage( ImageView imageView, String url) {
        GlideApp.with(imageView.getContext()).load(url).placeholder(R.drawable.jinbaiwan_257x157).into(imageView);
    }

    @BindingAdapter({"imgUrl", "placeHolder"})
    public static void loadImage(ImageView imageView, String url, Drawable placeholder) {
        GlideApp.with(imageView.getContext()).load(url).placeholder(placeholder).error(placeholder).dontAnimate().into(imageView);
    }

    public static void loadImage( ImageView imageView, String imgUrl, int placeHolderRes){
        GlideApp.with(imageView.getContext()).load(imgUrl).placeholder(placeHolderRes).error(placeHolderRes).into(imageView);
    }

    public static void loadImgByGlide(Context context, String imgUrl, int placeHolderRes){
        GlideApp.with(context).load(imgUrl).placeholder(placeHolderRes);
    }

}
